package software;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Use_user extends Use_done{
	private String Name=null;		//��ȡ��¼�û���
	private String Pwd=null;		//��ȡ��¼�的话
		
	private String NickName=null;	//�û��س�
	private String Email=null;
	private String Birthday="2000-1-1";
	private int Sex=1;
	private String Photo=null;

	private int Id=0;				//�û�ID
	private Date Dat_Register=new Date(0);

	private boolean State=false;
	private int Integral=0;
	
	public String getUsername(){
		//��ȡ�û���
		return Name;
	}
	public String getPassword(){
		//��ȱ��¼����
		return Pwd;
	}

	public String getNickName()
	{
		return NickName;
	}
	public String getEmail()
	{
		return Email;
	}

	public int getId(){
			//��ȡ�û�ID
			return getId(Name);
	}
	public String getName(){
		//��ȡ�û�ID
		return getName(Id);
	}

	public String getBirthday(){
		return Birthday;
	}
	public void setUsername(String s){
		//���õ�¼�û���
		Name=s;
	}
	public void setPassword(String s){
		//���õ�¼����
		Pwd=s;
	}
	public void setNickName(String s){
		NickName=s;
	}
	public void setEmail(String s){
		//����ע������
		Email=s;
	}
	public void setBirthday(String s){
		DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); 
		try{
			Date Day=fmt.parse(s);
			Birthday=fmt.format(Day);
		}catch(Exception e) {
			e.printStackTrace();
		}
		//���ó�������
	}
	public void setSex(int s){
		
		//�����Ա�
		Sex=s;
	}
	public void setId(int s){
		
			//�����Ա�
			Id=s;
		}
	public void setPhoto(String s){
		//����ͷ��
		Photo=s;
	}
	
	public boolean Che_NameR(){
		//check whether the username is used
		return Che_NameR(Name);
	}
	public boolean Che_EmailR(){
		
		return Che_EmailR(Email);
	}
	public boolean RegisterR(){
		int I=RegisterR(Name,Pwd,NickName,Email,Birthday,Sex,Photo);
		if(I==0)return false;
		else{
			Id=I;
			return true;
		}
	}
	public boolean Che_Login(){
		int I=Che_Login(Name,Pwd);
		if(I==0)return false;
		else{
			Id=I;
			return true;
		}
	}
}